public class selection_sort {
    private static void selection_sort(int[] array) {
        int temp, smallest;
        int smallest_index;
        for (int i = 0; i < array.length; i++) {
            smallest = array[i];
            smallest_index = i;
            for (int j = i; j < array.length; j++) {
                if (array[j] < smallest) {
                    smallest = array[j];
                    smallest_index = j;
                }
            }
            temp = array[i];
            array[i] = smallest;
            array[smallest_index] = temp;
        }
    }

    public static void main(String[] args) {
        int[] my_array = {1, 9, 45, 7, 15, -5, 2, 74, -27, 10};
        selection_sort(my_array);
        for (int i = 0; i < my_array.length; i++)
            System.out.printf("%d ", my_array[i]);
        System.out.println();
    }
}
